import {defineConfig} from 'vite'
import vue from '@vitejs/plugin-vue'
import path from 'path'
import legacy from "@vitejs/plugin-legacy";
import AutoImport from 'unplugin-auto-import/vite';
import Components from 'unplugin-vue-components/vite';
import {VantResolver} from '@vant/auto-import-resolver';

import babel from "vite-plugin-babel";
export default defineConfig({
    plugins: [
        vue(),
        legacy({
            // targets: ["defaults", "not IE 11"],
            targets: ['Chrome 66'],
            additionalLegacyPolyfills: ['regenerator-runtime/runtime'],
            modernPolyfills: true,
        }),
        AutoImport({
            resolvers: [VantResolver()],
        }),
        Components({
            resolvers: [VantResolver()],
        }),
        babel(),
    ],
    build: {
        target: 'es2015'
    },
    base: "./",
    resolve: {
        alias: {
            // 设置路径
            '~': path.resolve(__dirname, './'), // 设置别名
            '@': path.resolve(__dirname, './src')
        },
        extensions: ['.mjs', '.js', '.ts', '.jsx', '.tsx', '.json', '.vue']
    }, //本地服务器配置,打包后不会运行
    server: {
        host: '0.0.0.0',
        port: 8084, proxy: {
            "/dev-api": {
                target: "http://192.168.2.250:8082", changeOrigin: true, //是否跨域
                rewrite: (path) => path.replace(/^\/dev-api/, ""),
            }
        },
    },

})
